package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.IflightRefund;
import com.ktgj.flight.service.IIflightRefundService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 国际机票退票订单Controller
 * 
 * @author ruoyi
 * @date 2022-05-31
 */
@RestController
@RequestMapping("/refund")
public class IflightRefundController extends BaseController
{
    @Autowired
    private IIflightRefundService iflightRefundService;

    /**
     * 查询国际机票退票订单列表
     */
    @PreAuthorize(hasPermi = "system:refund:list")
    @GetMapping("/list")
    public TableDataInfo list(IflightRefund iflightRefund)
    {
        startPage();
        List<IflightRefund> list = iflightRefundService.selectIflightRefundList(iflightRefund);
        return getDataTable(list);
    }

    /**
     * 导出国际机票退票订单列表
     */
    @PreAuthorize(hasPermi = "system:refund:export")
    @Log(title = "国际机票退票订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IflightRefund iflightRefund) throws IOException
    {
        List<IflightRefund> list = iflightRefundService.selectIflightRefundList(iflightRefund);
        ExcelUtil<IflightRefund> util = new ExcelUtil<IflightRefund>(IflightRefund.class);
        util.exportExcel(response, list, "国际机票退票订单数据");
    }

    /**
     * 获取国际机票退票订单详细信息
     */
    @PreAuthorize(hasPermi = "system:refund:query")
    @GetMapping(value = "/{refundid}")
    public AjaxResult getInfo(@PathVariable("refundid") Long refundid)
    {
        return AjaxResult.success(iflightRefundService.selectIflightRefundById(refundid));
    }

    /**
     * 新增国际机票退票订单
     */
    @PreAuthorize(hasPermi = "system:refund:add")
    @Log(title = "国际机票退票订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IflightRefund iflightRefund)
    {
        return toAjax(iflightRefundService.insertIflightRefund(iflightRefund));
    }

    /**
     * 修改国际机票退票订单
     */
    @PreAuthorize(hasPermi = "system:refund:edit")
    @Log(title = "国际机票退票订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IflightRefund iflightRefund)
    {
        return toAjax(iflightRefundService.updateIflightRefund(iflightRefund));
    }

    /**
     * 删除国际机票退票订单
     */
    @PreAuthorize(hasPermi = "system:refund:remove")
    @Log(title = "国际机票退票订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundids}")
    public AjaxResult remove(@PathVariable Long[] refundids)
    {
        return toAjax(iflightRefundService.deleteIflightRefundByIds(refundids));
    }
}
